# ifndef CAENEVENT_H
# define CAENEVENT_H 


#include <iostream>
#include <fstream>
#include <ios>
#include <sstream>
#include "stdint.h"

using namespace std;

typedef unsigned char    uchar_t;


//! class that stores info about each event (single detector) 
class cCaenEvent{
	public: 
		//cCaenEvent{}; //!< constructor; used to set the statics (lastTimeStamp and correctionTime);
		int detNr;  //!< the detector number (channel)
		double timestamp; //(sec)  //!< the timestamp; read in multiples of 10ns from the file, but stored in seconds
		static double lastTimestamp; //(sec)  //!< the timestamp read previously; in seconds;
		//static double lastdetId; //(integer 0-3)  //!< the detId  read previously; timestamp reset fails if the same signal is inserted in different channels;
		static double correctionTime; //(sec) //!< a timevalue to be added to all timestamps; used to add the 32.5 days when the timestamp is reset;
		int trigId; //!<triggerId read from the file
		int energy;//!< the energy of the event
		double realEnergy; // !<the energy of the event,after energy calibration
		int isPileUp;//!< =1 if the event was marked as pile-up by the acquisition
		int isDead; //!< =1 if the event was marked as rejected for imposed dead time reasons
	
		friend ostream& operator<< (ostream& output, const cCaenEvent& p);
    	friend istream& operator>> (istream& input, cCaenEvent& p);
    	//int DecodeFromBinary(uchar_t[14]);
    	int DecodeFromBinary(uint8_t buffer[16]);
    	int Set(unsigned long long timestamp, int energy, int trigId, int channel);

};
#endif
